Add "extended" file metadata to API
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignAPIFile.php
old mode 100644 (file)
new mode 100755 (executable)
index 8829cd9..a1a6f26
@@ -86,7 +86,7 @@ class ForeignAPIFile extends File {
         * @return string
         */
        static function getProps() {
-               return 'timestamp|user|comment|url|size|sha1|metadata|mime';
+               return 'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype';
        }
 
        // Dummy functions...
@@ -169,6 +169,16 @@ class ForeignAPIFile extends File {
                return null;
        }
 
+       /**
+        * @return array|null extended metadata (see imageinfo API for format) or null on error
+        */
+       public function getExtendedMetadata() {
+               if ( isset( $this->mInfo['extmetadata'] ) ) {
+                       return $this->mInfo['extmetadata'];
+               }
+               return null;
+       }
+
        /**
         * @param $metadata array
         * @return array
@@ -245,10 +255,12 @@ class ForeignAPIFile extends File {
        }
 
        /**
-        * @todo FIXME: May guess wrong on file types that can be eg audio or video
         * @return int|string
         */
        function getMediaType() {
+               if ( isset( $this->mInfo['mediatype'] ) ) {
+                       return $this->mInfo['mediatype'];
+               }
                $magic = MimeMagic::singleton();
                return $magic->getMediaType( null, $this->getMimeType() );
        }